<template>
  <svg
    class="icon-svg"
    :style="{ fill: color || '', fontSize: `${size}rem` }"
    aria-hidden="true"
  >
    <use :xlink:href="iconName"></use>
  </svg>
</template>

<script setup lang="ts" name="Iconfont">
const props = defineProps({
  name: {
    type: String,
    required: true,
  },
  size: {
    type: [Number, String],
    default: 20,
  },
  color: {
    type: String,
  },
});

const iconName = computed(() => {
  return `#${props.name}`;
});
</script>

<style lang="scss" scoped>
.icon-svg {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
</style>
